<template>
  <div>
    <folder ref="folder" @setMenuStatus="setMenuStatus" @getMenuFolderId="getMenuFolderId" />
  </div>
</template>

<script>
import { getMenu } from '@/api/system/menu.js'
import folder from '@/views/folder/index.vue'
export default {
  components: {
    folder
  },
  data() {
    return {
      folderOpen: false,
      menuFlag: false
    }
  },
  created() {
  },
  methods: {
    setMenuStatus(that) {
      that.menuStatus = true
    },
    getMenuFolderId(that, callBack) {
      console.log('菜单文档库')
      var paramId = ''
      paramId = this.$route.query.id
      that.menuStatusId = paramId
      if (paramId === '' || paramId === undefined || paramId === null) {
        getMenu(this.$route.meta.id).then(response => {
          if (response.code === 200 && response.data !== null) {
            var menuUrlArr = []
            var tempMenuUrl = response.data.component
            if (tempMenuUrl !== null && tempMenuUrl !== '') {
              tempMenuUrl = tempMenuUrl.substring(tempMenuUrl.indexOf('?') + 1)
              var tempMenuUrlArr = tempMenuUrl.split('&')
              if (tempMenuUrlArr !== undefined && tempMenuUrlArr.length > 0) {
                tempMenuUrlArr.forEach(item => {
                  var temp = item.split('=')
                  if (temp !== undefined && temp[1] !== undefined) {
                    menuUrlArr.push(temp[1])
                  }
                })
                if (menuUrlArr.length > 0) {
                  that.menuStatusId = menuUrlArr[0]
                  callBack()
                }
              }
            }
          }
        })
      } else {
        callBack()
      }
    }
  }
}
</script>

<style scoped>

</style>
